﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RingControls.Extensions
{
    internal static class DoubleExtension
    {
        internal static double ToDegrees(this double radian)
        {
            return 180 * radian / Math.PI;
        }

        internal static double ToRadians(this double degree)
        {
            return degree * Math.PI / 180;
        }

        internal static double NormalizeDegree(this double degree)
        {
            while (degree < 0) degree += 360;
            while (360 <= degree) degree -= 360;

            return degree;
        }

        internal static double NormalizeRadian(this double radian)
        {
            var PIPI = 2 * Math.PI;
            while (radian < 0) radian += PIPI;
            while (PIPI <= radian) radian -= PIPI;

            return radian;
        }

        internal static double DegreeToScreen(this double degree)
        {
            degree -= 90;
            degree *= -1;

            return degree;
        }

        internal static double ScreenToDegree(this double degree)
        {
            degree -= 90;
            return degree;
        }

        internal static double RadianToScreen(this double radian)
        {
            radian -= Math.PI / 2;
            return radian;
        }
    }
}
